import React from 'react';
import FileUpload from 'util/FileUpload.jsx';

class FileUploadUtil extends React.Component {
  render() {
    /*set properties*/
    const options = {
      baseUrl: '/manage/product/upload.do',
      fileFieldName: 'upload_file',
      dataType: 'json',
      chooseAndUpload: true,
      uploadSuccess: res => this.props.onSuccess(res.data),
      uploadError: err => this.props.onError(err.message || '上传出了一点问题额'),
    }
    /*Use FileUpload with options*/
    /*Set two dom with ref*/
    return (
      <FileUpload options={options}>
        {/* <button ref="chooseBtn">choose</button>
        <button ref="uploadBtn">upload</button> */}
        <button className="btn btn-xs btn-default" ref="chooseAndUpload">选择图片</button>
      </FileUpload>
    )
  }
}

export default FileUploadUtil;